import 'package:dio/dio.dart';
import 'package:sainbainu/common/http/http.dart';

class GroupApi {
  /// 创建小组
  Future<Map<String, dynamic>> create(Map data) async {
    Response res = await Http.post('/api/social/group/add', data: data);
    return res.data;
  }

  /// 编辑小组
  Future<Map<String, dynamic>> update(Map data) async {
    Response res = await Http.post('/api/social/group/edit', data: data);
    return res.data;
  }

  /// 小组编辑详情
  Future<Map<String, dynamic>> info(Map<String, dynamic> params) async {
    Response res = await Http.get('/api/social/group/info', params: params);
    return res.data;
  }

  /// 我的小组列表
  Future<Map<String, dynamic>> myList(Map<String, dynamic> params) async {
    Response res = await Http.get('/api/social/group/my_list', params: params);
    return res.data;
  }

  /// 推荐小组列表
  Future<Map<String, dynamic>> recommentList(
    Map<String, dynamic> params,
  ) async {
    Response res = await Http.get(
      '/api/social/group/recommend_list',
      params: params,
    );
    return res.data;
  }

  /// 详细信息
  Future<Map<String, dynamic>> detail(Map<String, dynamic> params) async {
    Response res = await Http.get('/api/social/group/detail', params: params);
    return res.data;
  }

  /// 加入小组
  Future<Map<String, dynamic>> join(Map data) async {
    Response res = await Http.post('/api/social/group/join_member', data: data);
    return res.data;
  }

  /// 退出小组
  Future<Map<String, dynamic>> unjoin(Map data) async {
    Response res = await Http.post('/api/social/group/drop_member', data: data);
    return res.data;
  }

  /// 小组帖子列表
  Future<Map<String, dynamic>> groupContentList(
    Map<String, dynamic> params,
  ) async {
    Response res = await Http.get(
      '/api/social/note/group_list',
      params: params,
    );
    return res.data;
  }

  /// 成员列表
  Future<Map<String, dynamic>> memberList(
    Map<String, dynamic> params,
  ) async {
    Response res = await Http.get(
      '/api/social/group/member_list',
      params: params,
    );
    return res.data;
  }

  /// 移除成员
  Future<Map<String, dynamic>> dropMember(Map data) async {
    Response res = await Http.post('/api/social/group/drop_member', data: data);
    return res.data;
  }
}
